package sudroid.net;

import java.io.UnsupportedEncodingException;
import java.util.Date;
import sudroid.LogUtils;
import sudroid.ObjectWrapper;

public class HttpResponse extends ObjectWrapper
{
  public static final String EMPTY_CONTENT = "EMPTY_CONTENT";
  public int code;
  public String contentType;
  public byte[] datas;
  public String encoding;
  private ResponseHandler handler;
  public int length;
  public String message;
  public long sentDate;

  public HttpResponse()
  {
  }

  public HttpResponse(byte[] paramArrayOfByte, int paramInt1, String paramString1, int paramInt2, String paramString2, String paramString3, long paramLong)
  {
    this.datas = paramArrayOfByte;
    this.length = paramInt1;
    this.contentType = paramString1;
    this.code = paramInt2;
    this.message = paramString2;
    this.encoding = paramString3;
    this.sentDate = paramLong;
  }

  public static String getEncodingFromContentType(String paramString)
  {
    int j;
    if (paramString != null)
    {
      int i = paramString.indexOf("charset=");
      if (i != -1)
        j = i + 8;
    }
    for (String str = paramString.substring(j).trim(); ; str = "ascii")
      return str;
  }

  public String dump()
  {
    StringBuilder localStringBuilder1 = new StringBuilder();
    StringBuilder localStringBuilder2 = localStringBuilder1.append("code:");
    int i = this.code;
    StringBuilder localStringBuilder3 = localStringBuilder2.append(i).append("\nmessage:");
    String str1 = this.message;
    StringBuilder localStringBuilder4 = localStringBuilder3.append(str1).append("\nencoding:");
    String str2 = this.encoding;
    StringBuilder localStringBuilder5 = localStringBuilder4.append(str2).append("\ncontentType:");
    String str3 = this.contentType;
    StringBuilder localStringBuilder6 = localStringBuilder5.append(str3).append("\ncontentLength:");
    int j = this.length;
    StringBuilder localStringBuilder7 = localStringBuilder6.append(j).append("\ntime:");
    long l = this.sentDate;
    String str4 = new Date(l).toGMTString();
    StringBuilder localStringBuilder8 = localStringBuilder7.append(str4);
    return localStringBuilder1.toString();
  }

  public boolean process(ResponseHandler paramResponseHandler, Object[] paramArrayOfObject)
    throws Not2xxException
  {
    if (paramResponseHandler != null)
    {
      this.handler = paramResponseHandler;
      if (((this.code >= 200) && (this.code < 300)) || (this.code == 304))
        paramResponseHandler.run(this, paramArrayOfObject);
    }
    for (int i = 1; ; i = 0)
    {
      return i;
      StringBuilder localStringBuilder = new StringBuilder("Response code:");
      int j = this.code;
      String str = j;
      throw new Not2xxException(str);
    }
  }

  public boolean process(Object[] paramArrayOfObject)
    throws Not2xxException
  {
    ResponseHandler localResponseHandler = this.handler;
    return process(localResponseHandler, paramArrayOfObject);
  }

  public boolean processWithoutException(Object[] paramArrayOfObject)
  {
    try
    {
      ResponseHandler localResponseHandler = this.handler;
      boolean bool1 = process(localResponseHandler, paramArrayOfObject);
      bool2 = bool1;
      return bool2;
    }
    catch (Not2xxException localNot2xxException)
    {
      while (true)
      {
        LogUtils.e(localNot2xxException);
        boolean bool2 = false;
      }
    }
  }

  public void setHandler(ResponseHandler paramResponseHandler)
  {
    this.handler = paramResponseHandler;
  }

  public String toString()
  {
    try
    {
      byte[] arrayOfByte = this.datas;
      String str1 = getEncodingFromContentType(this.contentType);
      str2 = new String(arrayOfByte, str1);
      return str2;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      while (true)
      {
        LogUtils.e(localUnsupportedEncodingException);
        String str2 = "EMPTY_CONTENT";
      }
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.net.HttpResponse
 * JD-Core Version:    0.6.0
 */